using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text;
using System.Data; 
using yq.IBase; 
using yq.Dictionary; 
using yq.Basis; 
using yq.Model.Logic;
using System.Collections; 
using Db; 
using System.Data.Common;

namespace yq.Model.Base 
{
    ///<summary>
    /// User_Activation - 用户激活码 - 对象基础类
    /// </summary>
    ///<typeparam name="T"></typeparam>
    public abstract class IUserActivation<T> :ModelBase<UserActivation> where T : UserActivation, new()
    {
        /// <summary>
        /// 写入主键值
        /// </summary>
        /// <param name="Id">主键</param>
        protected internal override void SetKeyValue(dynamic Id)
        {
            this.RowsId = Id;
        }

        /// <summary>
        /// 获取主键值
        /// </summary>
        /// <returns></returns>
        protected internal override dynamic GetKeyValue()
        {
            return RowsId;
        }

        /// <summary>
        /// 为本对象赋值
        /// </summary>
        /// <param name="dy"></param>
        public override void SetValue(dynamic dy) 
        {
           this.RowsId=dy.RowsId;
           this.UserId=dy.UserId;
           this.RandomCode=dy.RandomCode;
           this.Version=dy.Version;
        } 

        #region 定义属性

     
         /// <summary>
        /// RowsId
        /// </summary>
        private String _RowsId = "";
      
        /// <summary>
        /// RowsId
        /// </summary>
        public String RowsId
        {
            get 
            {
              return   (this._RowsId); 
            }

            set 
            {
                    _RowsId= value;  
            }
        }
       
     
         /// <summary>
        /// 用户ID
        /// </summary>
        private String _UserId = "";
      
        /// <summary>
        /// 用户ID
        /// </summary>
        public String UserId
        {
            get 
            {
              return   (this._UserId); 
            }

            set 
            {
                    _UserId= value;  
            }
        }
       
     
         /// <summary>
        /// 用户激活随机码
        /// </summary>
        private String _RandomCode = "";
      
        /// <summary>
        /// 用户激活随机码
        /// </summary>
        public String RandomCode
        {
            get 
            {
              return   (this._RandomCode); 
            }

            set 
            {
                    _RandomCode= value;  
            }
        }
       
     
       

      #endregion 定义属性 

          protected internal override void SetValue(UserActivation info, DataRow row) 
          { 
               if (row == null) 
               { 
                 info.IsLoad = false; 
               }
               else 
               { 
                  info.IsLoad = true; 
                  
                  if(row["RowsId"]!= DBNull.Value)
                  {
                  info.RowsId=row["RowsId"].ToString();
                 }
                 
                  
                  if(row["UserId"]!= DBNull.Value)
                  {
                  info.UserId=row["UserId"].ToString();
                 }
                 
                  
                  if(row["RandomCode"]!= DBNull.Value)
                  {
                  info.RandomCode=row["RandomCode"].ToString();
                 }
                 
                  
                  if(row["Version"]!= DBNull.Value)
                  {
                  info.Version=row["Version"].ToString();
                 }
                 
               } 

          } 

        protected internal override void GetDbParameters(DbCommand comm, UserActivation info, DbHelper cn) 
        { 
             
                cn.AddInParameter(comm, "@RowsId", DbType.String,ParameterTool.GetObj( info._RowsId )); 
            
             
                cn.AddInParameter(comm, "@UserId", DbType.String,ParameterTool.GetObj( info._UserId )); 
            
             
                cn.AddInParameter(comm, "@RandomCode", DbType.String,ParameterTool.GetObj( info._RandomCode )); 
            
                
                cn.AddInParameter(comm,"@Version", DbType.String, Guid.NewGuid().ToString());
              

                cn.AddInParameter(comm,"@_versionOdl", DbType.String, info._Version); 
                 
        } 

    } 
} 